/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
* Copyright 2010, Center for Advanced Information Systems, Nanyang Technological University
*
* File name: ExactVerify.java
*
* Abstract: Verify the exact results from candidates
*
* Current Version:      0.1
* Auther:               Jin Changjiu
* Modified Date:        Feb.28,2010
*
*/

package gblend.exactquery;

import gblend.adjlistgraph.ALGraph;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Vector;


/**
 *
 * @author cjjin
 */
public class ExactVerify {

   private static NewUllmanVerify ullman = new NewUllmanVerify();
   private  Vector<ALGraph> exactResults = new Vector<ALGraph>();

   public Vector<MatchedGraph> verify(SNode query , QueryEngine qengine) throws SQLException, ClassNotFoundException
   {    
      ArrayList<ALGraph> candidateGraphs = qengine.getCandidateGraph();
      Vector<MatchedGraph> matchedgraph = new Vector<MatchedGraph>();

      for(int i = 0; i < candidateGraphs.size();i++)
      {
           if(ullman.verify(query, candidateGraphs.get(i)))
           {
                MatchedGraph tmpg = new MatchedGraph();
                tmpg.setid(candidateGraphs.get(i).getGraphidAsEntry());

                for(int j=0;j< ullman.getNodeset().size();j++)
                {
                    tmpg.addNodes(ullman.getNodeset().elementAt(j));
                }
                matchedgraph.addElement(tmpg);
                exactResults.addElement(candidateGraphs.get(i));
           }
         
      }

      return matchedgraph;
   }


   public Vector<ALGraph> getExactResults()
   {
        return exactResults;
   }

}
